package org.example.redis;

import org.apache.flink.api.connector.source.SplitEnumerator;
import org.apache.flink.api.connector.source.SplitEnumeratorContext;
import org.apache.flink.api.connector.source.SplitsAssignment;

import java.util.Collections;
import java.util.List;

public class RedisSplitEnumerator implements SplitEnumerator<RedisSplit, Void> {

    private final SplitEnumeratorContext<RedisSplit> context;

    public RedisSplitEnumerator(SplitEnumeratorContext<RedisSplit> context) {
        this.context = context;
    }

    @Override
    public void start() {
        context.assignSplits(new SplitsAssignment<RedisSplit>(new RedisSplit("redis-split"),0));
    }

    @Override
    public void handleSplitRequest(int subtaskId, String requesterHostname) {
        // No action needed
    }

    @Override
    public void addSplitsBack(List<RedisSplit> splits, int subtaskId) {
        // No action needed
    }

    @Override
    public void addReader(int subtaskId) {
        // No action needed
    }

    @Override
    public Void snapshotState(long checkpointId) throws Exception {
        return null;
    }


    @Override
    public void close() {
        // No action needed
    }
}
